package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TbPushData;
import com.ruoyi.system.service.ITbPushDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 推送日志数据关联表Controller
 * 
 * @author ruoyi
 * @date 2025-02-17
 */
@RestController
@RequestMapping("/system/data")
public class TbPushDataController extends BaseController
{
    @Autowired
    private ITbPushDataService tbPushDataService;

    /**
     * 查询推送日志数据关联表列表
     */
    @PreAuthorize("@ss.hasPermi('system:data:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbPushData tbPushData)
    {
        startPage();
        List<TbPushData> list = tbPushDataService.selectTbPushDataList(tbPushData);
        return getDataTable(list);
    }

    /**
     * 导出推送日志数据关联表列表
     */
    @PreAuthorize("@ss.hasPermi('system:data:export')")
    @Log(title = "推送日志数据关联表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbPushData tbPushData)
    {
        List<TbPushData> list = tbPushDataService.selectTbPushDataList(tbPushData);
        ExcelUtil<TbPushData> util = new ExcelUtil<TbPushData>(TbPushData.class);
        util.exportExcel(response, list, "推送日志数据关联表数据");
    }

    /**
     * 获取推送日志数据关联表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:data:query')")
    @GetMapping(value = "/{logId}")
    public AjaxResult getInfo(@PathVariable("logId") String logId)
    {
        return success(tbPushDataService.selectTbPushDataByLogId(logId));
    }

    /**
     * 新增推送日志数据关联表
     */
    @PreAuthorize("@ss.hasPermi('system:data:add')")
    @Log(title = "推送日志数据关联表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbPushData tbPushData)
    {
        return toAjax(tbPushDataService.insertTbPushData(tbPushData));
    }

    /**
     * 修改推送日志数据关联表
     */
    @PreAuthorize("@ss.hasPermi('system:data:edit')")
    @Log(title = "推送日志数据关联表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbPushData tbPushData)
    {
        return toAjax(tbPushDataService.updateTbPushData(tbPushData));
    }

    /**
     * 删除推送日志数据关联表
     */
    @PreAuthorize("@ss.hasPermi('system:data:remove')")
    @Log(title = "推送日志数据关联表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logIds}")
    public AjaxResult remove(@PathVariable String[] logIds)
    {
        return toAjax(tbPushDataService.deleteTbPushDataByLogIds(logIds));
    }
}
